package pers.baiban.sqltoword.convert;

import cn.hutool.core.util.StrUtil;
import pers.baiban.sqltoword.enums.TableIndex;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author 强子初
 * @since 2023/11/28
 */
@Component
public class StringToTableIndexConverter implements Converter<String, TableIndex> {

    @Override
    public TableIndex convert(String source) {
        for (TableIndex index  :TableIndex.values()) {
            if(StrUtil.equals(index.getVal(), source))
                return index;
        }
        return TableIndex.NIL;
    }
}